package com.m3958.firstgwt.client.constants;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.core.client.JsArrayString;
import com.google.inject.Inject;
import com.m3958.gwtutil.clientside.client.jso.MenuitemJso;

public class AppMenuAndCat {

//	private LocalMenuCatJso menuCatListJso;
	
	private String[] catKeyList = new String[]{"articleCat","xinjianCat","voteCat","assetCat","siteCat","userCat","othersCat","systemCat"};
	
//	private Map<String, String> i18catKeyMap = new HashMap<String, String>();
//	
//	private Map<String, String> i18menuKeyMap = new HashMap<String, String>();
	
	private Map<String,List<String>> menuListMap = new HashMap<String, List<String>>();
	
	@Inject
	private AppMenuConstants amcConstants;
	
	public AppMenuAndCat(){
	}
	
//	public String getcatKey(String title){
//		return i18catKeyMap.get(title);
//	}
//	
//	public String getMenuKey(String title){
//		return i18menuKeyMap.get(title);
//	}
	
	public void initMe(JsArray<MenuitemJso> menuitems){
		for(int i=0;i<menuitems.length();i++){
			MenuitemJso mij =menuitems.get(i); 
//			i18menuKeyMap.put(amcConstants.getString(mij.getUniqueName()), amcConstants.getString(mij.getUniqueName()));
			addtoMenuListMap(mij.getMenuItemCat(),mij.getUniqueName());
		}
//		for(String s : catKeyList){
//			i18catKeyMap.put(amcConstants.getString(s),s);
//		}
	}
	
	private void addtoMenuListMap(String catKey,String menuKey){
		if(menuListMap.get(catKey) == null){
			menuListMap.put(catKey, new ArrayList<String>());
		}
		menuListMap.get(catKey).add(menuKey);
	}
	
	public List<String> getSubMenuItems(String catKey){
		return menuListMap.get(catKey);
	}

	public String[] getCatKeyList() {
		return catKeyList;
	}
	
//	private boolean addToKeyList(String key){
//		for(String s : catKeyList){
//			if(s.equals(key)){
//				return false;
//			}
//		}
//		catKeyList.add(key);
//		return true;
//	}
//	
//	private final native LocalMenuCatJso getCatList()/*-{
//		return {siteCat:["website","diskfile"],
//				articleCat:["article","section"],catKeys:["siteCat","articleCat","xinjianCat","voteCat","othersCat","systemCat"]};
//	}-*/;
	
	
//	public final JsArray<JsArrayString> get
}
